package com.xiaobawang.knowledge.spider.config;

import com.xiaobawang.knowledge.spider.filter.TraceIdFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description 项目的自动配置类
 * @author 18101119
 * @date 2024/3/25 17:06
 * @email songxinhang2023@e-chinalife.com
 * @id 18101119
 * @phone 13001321080
 */
@Configuration
public class TraceIdConfig {
    /**
     * @author synhard
     * @id 18101119
     * @description 注册请求过滤器，为每个请求生成 traceId
     * @date 2024/3/25 17:07
     * @param
     * @return org.springframework.boot.web.servlet.FilterRegistrationBean<com.chinalife.cdp.config.filter.TraceIdFilter>
     */
    @Bean
    public FilterRegistrationBean<TraceIdFilter> traceIdFilter() {
        FilterRegistrationBean<TraceIdFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new TraceIdFilter());
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}